import React from 'react';
import './assistantTherapyTemplate.less';
import {browserHistory} from 'react-router';
import { Tabs ,Table,Button, Modal, Pagination, Form, message} from 'antd';
const TabPane = Tabs.TabPane;

//模板table
class AssistantTherapyTemplateTable extends React.Component{
    constructor(props){
        super(props);
        this.state={
            storeList:[],//门店列表
            pagesize: 10,// 每页显示的页数
            pageindex: 1,// 当前页
            storesCount:0,//门店总数
        }
    }
    componentWillMount() {}
    componentDidMount() {}

    //删除医生挂号费数据
    deleteDepartment(store) {
        Modal.confirm({
            title: '删除门店',
            content: '确认删除该挂号费数据吗?',
            cancelText:'取消',
            okText:'确定',
            onCancel: () => { message.info('取消删除该挂号费数据') },
            onOk: () => {
                //发送Ajax请求
            }
        })
    }
    //编辑医生挂号费信息
    editDepartment(store) {
        console.log(store);
        let paths = {
            pathname: 'addStoreForm',
            state: JSON.stringify(store),
        }
        browserHistory.push({
            pathname:paths.pathname,
            query:{},
            state:'haha'
        });
    }

    //分页
    changePage(pageindex) {
        this.setState({
            pageindex
        }, () => {
            this.getStoreList();
        });
    }
    render(){
        const columns = [
            {
                title: '序号',
                dataIndex: 'id',
                width: 60,
            },
            {
                title: '辅助理疗模板名称',
                dataIndex: 'assistantTherapyName',
                width: 130,
            }, {
                title: '关联科室',
                dataIndex: 'relatedDepartment',
                width: 120,
            },{
                title: '模板项目',
                dataIndex: 'templateProject',
                width: 350,
            },{
                title: '治疗费用',
                dataIndex: 'treatFee',
                width: 120,
            }, {
                title: '是否允许折扣',
                dataIndex: 'isDiscount',
                width: 120,
                render:text=> <span>{text == 1 ? "是" : text == 0 ? "否" : ""}</span>
            }, {
                title: '创建日期',
                dataIndex: 'createdTime',
                width: 200,
            },{
                title: '状态',
                dataIndex: 'status',
                width: 50,
                render: text => <Button type={text == 1 ? "danger" :"primary" }>{text == 1 ? "停用" : text == 0 ? "正常" : ""}</Button>
            }, {
                title: '操作',
                width: 200,
                render: (text, record) => (
                    <div>
                        <Button onClick={this.editDepartment.bind(this, record)} type="primary" >编辑</Button>
                        <Button onClick={this.deleteDepartment.bind(this, record)}  type="danger">删除</Button>
                    </div>
                )
            }
        ];
        return(
            <div>
                {/*增加按钮*/}
                <div className="storeAdd">
                    <Button onClick={() => { browserHistory.push('addAssistantTherapyTemplateForm') }} type="primary">
                        <img src={require('../../../../images/add.png')} alt=""/>
                        新增模板</Button>
                </div>
                <div className='all-roles-table'>
                    <Table
                        rowKey="id"
                        columns={columns}
                        dataSource={this.props.parentData}
                        pagination={false}
                        bordered
                    />
                </div>
                <div className="pagination">
                    <Pagination current={this.state.pageindex} total={this.state.managersCount || 1} defaultPageSize={this.state.pagesize} onChange={this.changePage.bind(this)} />
                </div>
            </div>
        )
    }
}


class AssistantTherapyTemplate extends React.Component {
    constructor(props){
        super(props);
        this.state={
            data:[{
                id:'1',
                assistantTherapyName:'头晕',
                relatedDepartment:'内科',
                templateProject:'儿童龋齿预防保健 次 (含4岁至学龄前儿童按齿科常规检查)2次；家庭巡诊 次 (含了解服务对象健康状况、指导疾病治疗和康复、进行健康咨询)1次；耳道冲洗 次 (含冲洗及生理盐水、注射器等)2次',
                treatFee:'￥55.00',
                isDiscount:'1',
                createdTime: '2017-12-12 15:30',
                status:'1',
            }]
        }
    }
    componentWillMount() {}
    componentDidMount() {
        this.getDepartmentsList();
    }
    //获取模板列表
    getDepartmentsList() {
        // ajax('get','').then(data=>{
        //     this.setState({
        //         storeList:data
        //     })
        // }).catch(err=>{
        //         console.log(err);
        //     })
    }
    handleTabChange(activeKey){
        console.log(activeKey);
    }

    render(){
        return (
            <div className="container">
                <div className="assistant-therapy-box">
                    <Tabs defaultActiveKey="1" onChange={this.handleTabChange.bind(this)} type="card">
                        <TabPane tab=" 小儿推拿" key="1"><AssistantTherapyTemplateTable parentData={this.state.data}></AssistantTherapyTemplateTable></TabPane>
                        <TabPane tab="针灸/按摩/火罐" key="2"><AssistantTherapyTemplateTable parentData={this.state.data}></AssistantTherapyTemplateTable></TabPane>
                        <TabPane tab="女性护理" key="3"><AssistantTherapyTemplateTable parentData={this.state.data}></AssistantTherapyTemplateTable></TabPane>
                    </Tabs>
                </div>
            </div>
        );
    }
}
export default AssistantTherapyTemplate;